﻿using System;
using System.IO;
using System.Text;

namespace Path类
{
	class Program
	{

		//路径有问题
		static void Main(string[] args)
		{
			string str = @"E:\壁纸\IMG\蝴蝶忍.jpd";
			//获取文件名
			Console.WriteLine(Path.GetFileName(str));
			//获取文件名字但不包含扩展名
			Console.WriteLine(Path.GetFileNameWithoutExtension(str));
			//获取文件扩展名
			Console.WriteLine(Path.GetExtension(str));
			//获取文件所在文件夹名字
			Console.WriteLine(Path.GetDirectoryName(str));
			//获取文件全路径
			Console.WriteLine(Path.GetFileName(str));
			//连接字符串路径
			Console.WriteLine(Path.Combine(@"E:\a\","b.txt"));

			//File类
			//读取并且按行切后放到字符串数组
			string[] cot= File.ReadAllLines(@"E:\Projects\untiy3d\守秘人\Assets\Dialogue\cc.txt", Encoding.Default);
			//绝对路径
			foreach(string c in cot)
			{
				Console.WriteLine(c);
			}
			
            //写入数据，会覆盖原数据
			File.WriteAllLines(@"E:\Projects\untiy3d\守秘人\Assets\Dialogue\cc.txt",new string[] { "我是头","我是身体"});
			//写入数据
			File.AppendAllText(@"E:\Projects\untiy3d\守秘人\Assets\Dialogue\cc.txt","我是腿");
			//读取放到字符串
			string st = File.ReadAllText(@"E:\Projects\untiy3d\守秘人\Assets\Dialogue\cc.txt", Encoding.Default);

			Console.WriteLine(st);
			Console.ReadKey();

		}
	}
}
